package br.ucb.sigplan.crud;

import java.util.List;

import br.ucb.sigplan.beans.Login;
import br.ucb.sigplan.beans.Professor;
import br.ucb.sigplan.dao.ProfessorDAO;
import br.ucb.sigplan.dao.impl.ProfessorDAOImpl;
import br.ucb.sigplan.exception.DAOException;

public class ProfessorCrud {
	private static ProfessorDAO professorDAO;
	
	private ProfessorCrud() {
		
	}
	
	public static ProfessorDAO getProfessorDAO() {
		if (professorDAO == null) {
			professorDAO = new ProfessorDAOImpl();
		}
		return professorDAO;
	}
	
	public static void insert(Professor professor) throws DAOException{
		getProfessorDAO().insert(professor);
	}
	
	public static List<Professor> findAll(){
		return getProfessorDAO().findAll();
	}
	
	public static Professor findById(Integer idProfessor){
		return getProfessorDAO().findById(idProfessor);
	}
	
	public static Professor findByLogin(Login login) {
		return getProfessorDAO().findByLogin(login);
	}
	
	public static Professor findByEmail(String email) {
		return getProfessorDAO().findByEmail(email);
	}
	
	public static void delete(Integer idprofessor){
		getProfessorDAO().delete(idprofessor);
	}
	
	public static void update(Professor professor) {
		getProfessorDAO().update(professor);
	}
	
	public static boolean isEmailCadastrado(String email) {
		return getProfessorDAO().findByEmail(email) != null;
	}
	
}
